package com.hsd.service.Impl;

import com.hsd.entity.Advertisement;
import com.hsd.entity.Category;
import com.hsd.entity.Goods;
import com.hsd.mapper.AdvertisementMapper;
import com.hsd.mapper.CategoryMapper;
import com.hsd.mapper.GoodsMapper;
import com.hsd.service.IFloorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class IFloorServiceImpl implements IFloorService {
    @Resource
    private CategoryMapper categoryMapper;
    @Resource
    private GoodsMapper goodsMapper;
    @Resource
    private AdvertisementMapper advertisementMapper;


    @Override
    public Map<String, Object> findByFloor(String floor) {
        Map<String,Object> map=new HashMap<>();
        Advertisement advertisement = advertisementMapper.selectByTagToAD(floor);
        Category category = categoryMapper.slectByTag(floor);
        List<Goods> goodsList = goodsMapper.selectByTag(floor);
        map.put("ad",advertisement);
        map.put("category",category);
        map.put("goodies",goodsList);
        return map;
    }

    @Override
    public List<Map<String, Object>> findFloors(Integer floors) {
        List<Map<String,Object>> list=new ArrayList<>();
        for (int i =1; i <=floors; i++) {
            list.add(findByFloor(i+"F"));
        }
        return list;
    }
}
